math.js ➔ factorial   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 2
1
/**
2
 * calculate facorial of the number
3
 * @param {number} num
0 ignored issues
show
Documentation introduced by
The parameter num does not exist. Did you maybe forget to remove this comment?
Loading history...
4
 * @returns {number} facorial of the number
5
 */
6
export function factorial(n) {
7
    return (n > 1) ? n * factorial(n - 1) : 1;
8
}
9
10
/**
11
 * calculate Fibonacci Sequence
12
 * @param {number} num
13
 * @returns {number} Fibonacci number
14
 */
15
export function fibonacci(n) {
16
    return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
17
}
18